package com.ios.palette.domain;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

/**
 * @author 志刚
 *
 */
@Entity
@Table(name = "user")
public class User implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "id")
	private Long id;

	private String username;
	private String password;
	private String introduce;
	private String image;
	@ManyToMany(targetEntity = User.class)
	@JoinTable(name = "user_user", joinColumns = @JoinColumn(name = "concern_id", referencedColumnName = "id") , inverseJoinColumns = @JoinColumn(name = "fans_id", referencedColumnName = "id") )
	private Set<User> concern=new HashSet<>();

	@ManyToMany(targetEntity = User.class)
	@JoinTable(name = "user_user", joinColumns = @JoinColumn(name = "fans_id", referencedColumnName = "id") , inverseJoinColumns = @JoinColumn(name = "concern_id", referencedColumnName = "id") )
	private Set<User> fans=new HashSet<>();

	@OneToMany(targetEntity = Status.class, mappedBy = "user", fetch = FetchType.EAGER)
	@Cascade(CascadeType.ALL)
	private Set<Status> statuses=new HashSet<>();

	@OneToMany(fetch = FetchType.EAGER)
	@JoinColumn(name = "user_id", referencedColumnName = "id")
	@Cascade(CascadeType.ALL)
	private Set<Status> collection=new HashSet<>();
	
	@ManyToMany(targetEntity=Status.class)
	@JoinTable(name="user_status_like",joinColumns=@JoinColumn(name="user_id",referencedColumnName="id"),inverseJoinColumns=@JoinColumn(name="status_id",referencedColumnName="id"))
	private Set<Status> liker=new HashSet<>();
	/**
	 * @return the id
	 */

	public Long getId() {
		return id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @return the introduce
	 */
	public String getIntroduce() {
		return introduce;
	}

	/**
	 * @param introduce
	 *            the introduce to set
	 */
	public void setIntroduce(String introduce) {
		this.introduce = introduce;
	}

	/**
	 * @return the image
	 */
	public String getImage() {
		return image;
	}

	/**
	 * @param image
	 *            the image to set
	 */
	public void setImage(String image) {
		this.image = image;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	/**
	 * @return the password
	 */
	public String getPassword() {
		return password;
	}

	/**
	 * @param password
	 *            the password to set
	 */
	public void setPassword(String password) {
		this.password = password;
	}

	/**
	 * @return the concern
	 */
	public Set<User> getConcern() {
		return concern;
	}

	/**
	 * @return the fans
	 */
	public Set<User> getFans() {
		return fans;
	}

	/**
	 * @return the statues
	 */
	public Set<Status> getstatues() {
		return statuses;
	}

	/**
	 * @return the collection
	 */
	public Set<Status> getCollection() {
		return collection;
	}

	/**
	 * @param concern the concern to set
	 */
	public void setConcern(Set<User> concern) {
		this.concern = concern;
	}

	/**
	 * @param fans the fans to set
	 */
	public void setFans(Set<User> fans) {
		this.fans = fans;
	}

	/**
	 * @param statues the statues to set
	 */
	public void setstatues(Set<Status> statuses) {
		this.statuses = statuses;
	}

	/**
	 * @param collection the collection to set
	 */
	public void setCollection(Set<Status> collection) {
		this.collection = collection;
	}
}
	